import os.path
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
file = "file:///" + os.path.abspath("html3") + "/popup.html"
driver.get(file)
# alter
btn = driver.find_elements(By.TAG_NAME, "button")
# btn[0].click()
# # alter 切换到alter弹窗
# time.sleep(2)
# alter = driver.switch_to.alert
# alter.accept()

# confirm
# time.sleep(2)
# btn[1].click()
# # 切换弹窗
# alter = driver.switch_to.alert
# time.sleep(1)
# # 点击确定
# alter.accept()
# alter.dismiss()

# prompt
btn[2].click()
alter = driver.switch_to.alert
alter.send_keys("你好啊")
print(alter.text)
time.sleep(2)
alter.accept()
alter.dismiss()


# 关闭弹窗
driver.quit()